package com.xjl.app.controller;

import com.xjl.app.EntityDTO.DeviceDTO;
import com.xjl.app.EntityDTO.StationDTO;
import com.xjl.app.convert.DeviceDTODOConvert;
import com.xjl.app.convert.StationDTODOConcert;
import com.xjl.app.domain.EntityDO.DeviceDO;
import com.xjl.app.domain.EntityDO.StationDO;
import com.xjl.app.domain.convert.DeviceDOConvert;
import com.xjl.app.domain.convert.StationDOConcert;
import com.xjl.app.infra.entity.Devices;
import com.xjl.app.infra.entity.Station;
import com.xjl.app.infra.service.StationService;
import com.xjl.app.service.StationDTOService;
import com.xjl.common.web.Res.Result;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("alarm/station")
@RequiredArgsConstructor
public class StationDTOController {

    private final StationService stationService;
    private final StationDTOService stationDTOService;
    @PostMapping("add")
    public Result addDevice(@RequestBody StationDTO stationDTO){


        Station station = stationDTOService.save(stationDTO);
        if(station!=null){
            return Result.ok(station);
        }
        log.error("添加站点失败! \n data = {}",stationDTO);
        return Result.error();
    }

}
